<template>
  <div class="finish">
    <div class="header">
      <el-select v-model="value" filterable placeholder="处理人">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
          :disabled="item.disabled"
        ></el-option>
      </el-select>
      <span style="margin-left:830px">合计完成语料：xxxx条</span>
    </div>
    <div class="center">
      <p style="margin: 20px 10px;">已完成语料列表</p>
      <el-table border :data="tableData" style="width: 100%;text-align: center">
        <el-table-column fixed prop="materialId" label="原始语料ID" width="150"></el-table-column>
        <el-table-column prop="content" label="预料内容" width="350"></el-table-column>
        <el-table-column prop="num" label="已标注句子数量" width="120"></el-table-column>
        <el-table-column prop="userId" label="处理人" width="150"></el-table-column>
        <el-table-column prop="processTime" label="处理时间" width="279"></el-table-column>
        <el-table-column label="操作" width="150">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>

    <div class="footer">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="cur"
        :page-sizes="[5, 10, 20, 40]"
        :page-size="size"
        :pager-count="5"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { finishlist } from "../../api/http.js";
import axios from "axios";
export default {
  name: "Finish",
  data() {
    return {
      tableData: [],

      total: 20, //总条数
      cur: 1, //当前页数
      size: 10, //每页显示条数

      options: [
        {
          value: "选项1",
          label: "黄金糕"
        },
        {
          value: "选项2",
          label: "双皮奶"
        }
      ],
      value: ""
    };
  },
  mounted() {
    this.listdata();
  },
  methods: {
    handleClick(row) {
      console.log(row);
      this.$router.push("/page");
    },
    listdata() {
      //已完成数据列表
      //封装的接口不能使用对象传进去
      
      var that = this;
      axios
        .post("/api/findPageByUserId", {
          userId: JSON.parse(localStorage.getItem("userinfo")).data.userId,
          size: this.size,
          current: this.cur
        })
        .then(function(res) {
          console.log(res);
          that.tableData = res.data.data.records; //列表页数据

          console.log(res.data); //分页数据
          var datavaclue = res.data.data
          that.total = datavaclue.total; //总条数

        })
        .catch(function(error) {
          console.log(error);
        });
    },
    //已完成数据列表

    // 初始页currentPage、初始每页数据数pagesize和数据data
    handleSizeChange: function(size) {
      this.size = size;
      console.log(this.pagesize); //每页下拉显示数据
      this.listdata();
    },

    handleCurrentChange: function(current) {
      this.cur = current;
      console.log(current);
      console.log(this.cur);
      //点击第几页
      this.listdata();
    }
  }
};
</script>
<style scoped>
.finish {
  width: 1200px;
  margin: 0 auto;
}

.header {
  width: 1200px;
  height: 60px;
  line-height: 60px;
  display: flex;
}

.center {
  width: 1200px;
  /* height: 800px; */
  /* background: rgb(170, 170, 163); */
}

.footer {
  width: 500px;
  height: 60px;
  margin: 40px auto;
}
</style>